home *** CD-ROM | disk | FTP | other *** search
/ PC Pro 2005 June (DVD) / DPPRO0605DVD.iso / Install / program files / Borland / BDS / 3.0 / Welcomepage / JS / BDSHOME.JS next >
Encoding:
JavaScript  |  2004-10-22  |  4.2 KB  |  186 lines

  1. /*
  2.     BDS Welcome Page XML routines
  3.  
  4.     Copyright (c) 2004 Borland Software Corporation
  5.  
  6. */
  7.  
  8. //bdshome.jds
  9.  
  10.  
  11. //Module Variables
  12. var fileSystemObject = new ActiveXObject("Scripting.FileSystemObject");
  13.  
  14. //Action Functions
  15. function openProject()
  16. {
  17.     external.Application.MainForm.FileOpenProjectItem.Click;
  18. }
  19.  
  20. function newProject()
  21. {
  22.     external.Application.MainForm.FileNewItem.Click;
  23. }
  24.  
  25. function openFile()
  26. {
  27.     external.Application.MainForm.FileOpenItem.Click;
  28. }
  29.  
  30. function newFile()
  31. {
  32.     external.Application.MainForm.SearchFileFindItem.Click;
  33. }
  34.  
  35. function viewPrjMgrItem()
  36. {
  37.     external.Application.MainForm.ViewPrjMgrItem.Click;
  38. }
  39.  
  40. function openHelp()
  41. {
  42.     external.Application.MainForm.HelpInprisePage.Click;
  43. }
  44.  
  45. function openHelpCSTutorial()
  46. {
  47.     external.Application.MainForm.HelpCsTutorialItem.Click;
  48. }
  49.  
  50. function openDExplore(alink)
  51. {
  52.     var session;
  53.     session = new ActiveXObject("DExplore.AppObj");
  54.     session.SetCollection("ms-help://borland.bds3", "");
  55.     session.Contents();
  56.     session.DisplayTopicFromUrl(alink);
  57.     // session.SyncContents(alink);
  58. }
  59.  
  60. //file manipulation functions
  61. function ExtractPathedFileFromCaption(FileString)
  62. {
  63.     return FileString.substring(FileString.indexOf(' ')+1, FileString.length);
  64. }
  65.  
  66. function ExtractValuesFromKeyString(KeyString)
  67. {
  68.     var KeyStringArray = new Array();
  69.     KeyStringArray = KeyString.split(',');
  70.     return KeyStringArray;
  71. }
  72.  
  73. function ClickMenu(Index)
  74. {
  75.     var MenuItem = external.Application.MainForm.FileClosedFilesItem.GetItems(Index);
  76.     if (MenuItem != null)
  77.     {
  78.         MenuItem.Click;
  79.     }
  80.     window.location.reload(true);
  81. }
  82.  
  83. function GetMenuText(Caption, Index)
  84. {
  85.     var Text = "";
  86.     var Filename = "";
  87.  
  88.     if (Caption != "-")
  89.     {
  90.         var pick = Caption.substring(1, 2);
  91.         if (pick < "5")
  92.         {
  93.             Text = Caption.substr(3);
  94.         }
  95.     }
  96.     Filename = Text;
  97.     var i = Text.lastIndexOf("\\");
  98.     if (Text.length > 0 && i > 0)
  99.     {
  100.         Text = Text.substr(i + 1);
  101.     }
  102.     if (Text != "")
  103.     {
  104.         Text = "<a class=\"filename\" title=\"" + Filename + "\" href=\"bds:/default.htm\" onclick=\"ClickMenu(" + Index + ")\">" + Text + "</A>";
  105.     }
  106.     return Text;
  107. }
  108.  
  109. function GetFileModifiedString(PathedFile)
  110. {
  111.     if(fileSystemObject != null)
  112.     {
  113.         if(fileSystemObject.FileExists(PathedFile))
  114.         {
  115.             var fModified = false;
  116.             var objDateFile = new Date(fileSystemObject.GetFile(PathedFile).DateLastModified);
  117.             return objDateFile.toLocaleDateString() + " " + objDateFile.toLocaleTimeString();
  118.         } else {
  119.             return "File not found";
  120.         }
  121.     } else {
  122.         return "Unable to read file date";
  123.     }
  124. }
  125.  
  126. function GetFileExtension(filename)
  127. {
  128.     return filename.substring(filename.lastIndexOf("."));
  129. }
  130.  
  131. function IsProjectGroup(filename)
  132. {
  133.     var fileExt = GetFileExtension(filename);
  134.     var pattern = /\.bdsgroup/;
  135.     if (pattern.test(fileExt))
  136.     {
  137.         return true;
  138.     } else {
  139.         return false;
  140.     }
  141. }
  142.  
  143. //Build a table of recent projects
  144. function RenderProjectsModule()
  145. {
  146.     var FColCnt=2;
  147.     var ProjectsTab = document.getElementById('recentprojects');
  148.     var ReopenMenu = external.Application.MainForm.FileClosedFilesItem;
  149.     var FRowCnt = ReopenMenu.Count()+1;
  150.     if(ProjectsTab)
  151.     {
  152.         var filecount = 0;
  153.         for(var i=1; i<FRowCnt ; i++)
  154.         {
  155.             var MenuItem = ReopenMenu.GetItems(i-1);
  156.             var MenuText = GetMenuText(MenuItem.Caption, MenuItem.MenuItemIndex);
  157.             var Filename = ExtractPathedFileFromCaption(MenuItem.Caption);
  158.             filecount++;
  159.             // Only display files that exist
  160.             if (MenuText != "" && fileSystemObject != null && fileSystemObject.FileExists(Filename))
  161.             {
  162.                 var row = ProjectsTab.insertRow();
  163.                 if(filecount % 2 != 0)
  164.                 {
  165.                     row.className = 'whiterow';
  166.                 } else {
  167.                     row.className = 'featuretable';
  168.                 }
  169.                 var cell = row.insertCell();
  170.                 cell.style.whiteSpace = "nowrap";
  171.                 if (IsProjectGroup(MenuText))
  172.                 {
  173.                     cell.innerHTML = "<img class=recentprojectimg src=\"bds:/images/project_group.gif\"> " + MenuText;
  174.                                         cell.vAlign = "middle";
  175.                 } else {
  176.                     cell.innerHTML = "<img class=recentprojectimg src=\"bds:/images/project.gif\"> " + MenuText;
  177.                                         cell.vAlign = "middle";
  178.                 }
  179.                 var cell = row.insertCell();
  180.                 cell.style.whiteSpace = "nowrap";
  181.                 cell.innerHTML = GetFileModifiedString(Filename);
  182.             }
  183.         }
  184.     }
  185. }
  186.